package org.btik.light.tool;

import java.security.SecureRandom;

/**
 * 生成UUID
 */
public abstract class UuidUtil {
    private static final SecureRandom secureRandom;

    static {
        long now = System.currentTimeMillis();
        secureRandom = new SecureRandom(ByteUtil.long2ByteArr(now));
    }


    public static byte[] uuid(int length) {
        byte[] uuid = new byte[length];
        secureRandom.nextBytes(uuid);
        return uuid;
    }

    public static String uuidString(int length) {
        return ByteUtil.toHexString(uuid(length));
    }


}
